package com.zr.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.json.JSONArray;

import com.zr.service.FunctionService;
import com.zr.service.RoleService;
import com.zr.service.impl.FunctionServiceImpl;
import com.zr.service.impl.RoleServiceImpl;

/**
 * Servlet implementation class ShowRole1
 */

public class ShowRole1 extends HttpServlet {
    private static final long serialVersionUID = 1L;
    RoleService roleService = new RoleServiceImpl();
    FunctionService functionService = new FunctionServiceImpl();

    /**
     * @see HttpServlet#HttpServlet()
     */
    public ShowRole1() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        // TODO Auto-generated method stub
        doPost(request, response);
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        // TODO Auto-generated method stub
        response.setCharacterEncoding("utf8");
        PrintWriter writer = response.getWriter();
        JSONArray jsonArray = roleService.getUserFuncs(-1, functionService.getAllFuncs());
        writer.write(jsonArray.toString());
    }

}
